package com.nchu.student_score.controller;

import com.github.pagehelper.PageInfo;
import com.nchu.student_score.model.Teacher;
import com.nchu.student_score.service.TeacherService;
import com.nchu.student_score.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Resource
    TeacherService teacherService;

    @RequestMapping("getTeacher/{currPage}")
    public PageInfo<Teacher> getTeacherList(@RequestBody Teacher teacher,@PathVariable Integer currPage){
        return teacherService.getTeacherList(teacher,currPage);
    }

    @RequestMapping("initTeacherPwd")
    public ResultVo<Teacher> initTeacherPwd(@RequestBody Teacher teacher){
        return teacherService.initTeacherPwd(teacher);
    }

    @RequestMapping("updateTeacher/{oldTeacherId}")
    public ResultVo<Teacher> updateTeacher(@RequestBody Teacher teacher,@PathVariable Integer oldTeacherId){
        return teacherService.updateTeacher(teacher,oldTeacherId);
    }

    @RequestMapping("getTeachers/{academyId}")//根据学院查询教师
    public ResultVo<Teacher> getTeachers(@PathVariable Integer academyId){
        return teacherService.getTeachers(academyId);
    }
}
